
package com.jf.cloud.delivery.controller.supplier;

import com.jf.cloud.api.delivery.dto.DeliveryOrderDTO;
import com.jf.cloud.api.delivery.vo.DeliveryOrderFeignVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.delivery.service.DeliveryOrderService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zz on 2020/05/15.
 */
@Controller
@RestController("supplierOrderDeliveryController")
@RequestMapping("/s/order_delivery")
@Tag(name = "供应商订单物流包裹")
public class OrderDeliveryController {

    @Autowired
    private  DeliveryOrderService deliveryOrderService;

    @GetMapping("/info")
    @Operation(summary = "查询订单物流包裹信息" , description = "查询订单物流包裹信息")
    public ServerResponseEntity<List<DeliveryOrderFeignVO>> page(@RequestParam("orderId") Long orderId) {
        List<DeliveryOrderFeignVO> deliveryOrders = deliveryOrderService.getByDeliveryByOrderId(orderId);
        return ServerResponseEntity.success(deliveryOrders);
    }

    /**
     * 修改订单物流包裹信息
     */
    @PutMapping("/update")
    public ServerResponseEntity<Void> updateOrderDeliveries(@RequestBody List<DeliveryOrderDTO> list) {
        deliveryOrderService.updateOrderDeliveries(list);
        return ServerResponseEntity.success();
    }

    @GetMapping("/{deliveryOrderId}")
    @Operation(summary = "物流包裹查询接口" , description = "根据orderDeliveryId查询订单包裹信息")
    @Parameter(name = "deliveryOrderId", description = "订单物流包裹id" )
    public ServerResponseEntity<DeliveryOrderFeignVO> deliveryOrder(@PathVariable("deliveryOrderId") Long deliveryOrderId) {
        DeliveryOrderFeignVO deliveryOrder = deliveryOrderService.deliveryOrderItemInfo(deliveryOrderId);
        return ServerResponseEntity.success(deliveryOrder);
    }

}
